﻿using FineUI;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZHDJ.Core.Util;
using ZHDJ.Data;
using ZHDJ.Data.Models.JoinParty;
using ZHDJ.JoinParty.BLL;
using ZHDJ.WebPage;

namespace JoinParty.admin.FlowStep
{
    public partial class Registration : PageBase
    {
        public string RegistrationContent { get; set; }
        public string BranchOpinionContent { get; set; }

        #region ViewPower

        /// <summary>
        /// 本页面的浏览权限，空字符串表示本页面不受权限控制
        /// </summary>
        public override string ViewPower
        {
            get
            {
                return "";
            }
        }

        #endregion
        #region Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
                LoadData();
            }
        }
        private void BindData()
        {
            SetPageShowContent();
        }

        private void LoadData(string IsSave = "")
        {
            btnClose.OnClientClick = ActiveWindow.GetHideReference();
            PartyJoinLinkExample oModel = DB.PartyJoinLinkExamples.Find(this.CurrentStandID);

            PartyJoinProcess ps = DB.PartyJoinProcesss.Find(this.CurrentStepID);
            this.lbWorkGuide.Text = Convert.ToString(ps.WorkPoint) ?? "";
            if (!string.IsNullOrEmpty(oModel.Remark))
            {
                this.RegistrationContent = oModel.Remark;
            }
            if (this.CurrentStepID == ProcesUtil.JoinStep15 || this.CurrentStepID == ProcesUtil.JoinStep16)
            {
                if (oModel.Status == 0)
                {
                    this.ddlPoliticalReview.SelectedValue = "1";
                }
                else
                {
                    this.ddlPoliticalReview.SelectedValue = Convert.ToString(oModel.Status);
                }
            }
            else if (this.CurrentStepID == ProcesUtil.JoinStep4 || this.CurrentStepID == ProcesUtil.JoinStep12 ||
                         this.CurrentStepID == ProcesUtil.JoinStep24 || this.CurrentStepID == ProcesUtil.JoinStep36)
            {
                var model = DB.partyjoinpublicitys.Where(a => a.StandID == this.CurrentStandID).FirstOrDefault();
                if (model != null)
                {
                    if (Convert.ToString(model.NoticeTime) != "")
                        this.txtTitle.Text = model.NoticeTime;
                }
            }
            else if (this.CurrentStepID == ProcesUtil.JoinStep10 || this.CurrentStepID == ProcesUtil.JoinStep17)
            {
                partyjointrained train = DB.partyjointraineds.Find(CurrentStandID);
                if (train != null)
                {
                    this.RegistrationContent = train.TrainedOpinion;
                    //this.heBranchOpinion.Text = train.BranchOpinion;
                    this.BranchOpinionContent = train.BranchOpinion;
                    imgPhoto.ImageUrl = UpFileBusiness.GetFileUrl(train.ImageUrlID);
                }
            }
            //页面只读显示
            if (this.ReadOnly.Trim() == "1")
            {
                this.btnSubmit.Visible = false;
                this.btnSaveClose.Visible = false;
                //if (IsJoinPartyAdmin && this.CurrentStepID != ProcesUtil.JoinStep9)
                //{
                //    this.btnSaveClose.Visible = true;
                //}
            }
            //设置输入框默认值
            else if (string.IsNullOrEmpty(oModel.Remark))
            {
                switch (CurrentStepID)
                {
                    case ProcesUtil.JoinStep6:
                        this.RegistrationContent = string.Format("<span style=\"white - space:pre\"></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 关于同意<u>&nbsp; &nbsp; &nbsp;</u>同志列为入党积极分子的批复<div><div><u>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</u>党支部：</div><div><br></div><div><span style=\"white - space:pre\"></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 经<u>&nbsp; &nbsp;&nbsp;</u>年<u>&nbsp; &nbsp;&nbsp;</u>月<u>&nbsp; &nbsp;&nbsp;</u>日<u>&nbsp; &nbsp;&nbsp;</u>审核，同意将<u>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</u>同志列为入党积极分子，请各支部做好该同</div><div><br></div><div>志的培养、考察等工作。</div><div><br></div><div><span style=\"white - space:pre\"></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;特此批复</div><div><span style=\"white - space:pre\">									</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<u>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</u></div><div><span style=\"white - space:pre\">								</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<u>&nbsp; &nbsp; &nbsp;&nbsp;</u>年<u>&nbsp; &nbsp; &nbsp;&nbsp;</u>月<u>&nbsp; &nbsp; &nbsp;&nbsp;</u>日</div></div>");
                        break;
                    case ProcesUtil.JoinStep14:
                        this.RegistrationContent = string.Format("<div style=\"text - align: left; \"><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;关于同意____同志为发展对象的批复</b></div><div style=\"text - align: left; \">____支部：</div><div style=\"text - align: left; \">&nbsp; &nbsp; &nbsp;《关于将____同志进行发展对象备案的报告》收悉，经研究，同意____同志为发展对象。</div><div style=\"text - align: left; \"><br></div><div style=\"text - align: left; \">&nbsp; &nbsp; 请按照发展党员工作有关规定，继续做好对____同志的培养教育和考察工作，认真组织政治审查、短期集中培训工作，并及时将有关情况报告党委预审。</div><div style=\"text - align: left; \"><br></div><div style=\"text - align: left; \">&nbsp; &nbsp; 特此批复</div><div style=\"text - align: left; \"><br></div><div style=\"text - align: left; \">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;____党支部</div><div style=\"text - align: left; \">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 年 &nbsp; 月 &nbsp; 日</div>");
                        break;
                }
            }
        }



        private void SaveData(bool isClose, bool AdminSave = false)
        {
            string Message = "";///接收处理流程反馈的消息主要判断当前步骤是否已审核过
            string outMassage = "";

            bool bResult = false;
            PartyJoinLinkExample oModel = DB.PartyJoinLinkExamples.Find(this.CurrentStandID);
            if (AdminSave)
            {
                if (this.CurrentStepID == ProcesUtil.JoinStep33)
                    oModel.Remark = this.Request.Form["editor2"];
                else if (this.CurrentStepID == ProcesUtil.JoinStep4 || this.CurrentStepID == ProcesUtil.JoinStep12 ||
                    this.CurrentStepID == ProcesUtil.JoinStep24 || this.CurrentStepID == ProcesUtil.JoinStep36)
                {
                    var model = DB.partyjoinpublicitys.Where(a => a.StandID == this.CurrentStandID && a.StepID == this.CurrentStepID).FirstOrDefault();
                    if (model == null)
                    {
                        PartyJoinProcess ps = DB.PartyJoinProcesss.Find(this.CurrentStepID);
                        string st = ps.ProcessName;
                        string[] sArray = st.Split('、');
                        var app = DB.PartyJoinApplycation.Find(this.AppllicationID);
                        model = new partyjoinpublicity();
                        model.ID = StringHelper.NewID;
                        model.StandID = this.CurrentStandID;
                        model.StepID = this.CurrentStepID;
                        model.AppllicationID = this.AppllicationID;
                        model.LoginID = app.LoginID;
                        model.Category = "publicity";
                        model.Title = "关于" + app.UserName + "同志" + sArray[1] + "的信息公告";
                        model.CreateTime = DateTime.Now;
                        model.NoticeTime = txtTitle.Text;
                        DB.partyjoinpublicitys.Add(model);
                    }
                    else
                    {
                        model.NoticeTime = this.txtTitle.Text;
                        model.CreateTime = DateTime.Now;
                    }
                    oModel.Remark = this.Request.Form["editor1"];
                }
                else if (this.CurrentStepID == ProcesUtil.JoinStep13 || this.CurrentStepID == ProcesUtil.JoinStep20)
                {
                    oModel.Remark = this.Request.Form["editor1"];
                    oModel.Remark2 = this.Request.Form["editor2"];
                }
                else
                {
                    oModel.Remark = this.Request.Form["editor1"];
                }

                DB.SaveChanges();
            }
            else
            {
                oModel.Remark = this.Request.Form["editor1"];
                oModel.HandleUserID = this.CurrentUser.ID;
                oModel.HandleUserName = this.CurrentUser.UserName;
                oModel.HandleTime = DateTime.Now;
                oModel.Status = (int)Enum_FlowStanceStatus.通过;

                switch (oModel.CurrentStepID)
                {
                    case ProcesUtil.JoinStep15: //政审
                    case ProcesUtil.JoinStep16: //预审
                    case ProcesUtil.JoinStep38: //党委审批（3个月内）及批复
                        oModel.Status = Convert.ToInt32(this.ddlPoliticalReview.SelectedValue);
                        break;
                }
                switch (this.CurrentStepID)
                {
                    case ProcesUtil.JoinStep10:
                    case ProcesUtil.JoinStep17:
                        oModel.Remark = "";

                        bResult = ProcesUtil.ApprovalProcesStep(oModel, out Message);
                        if (bResult)
                        {
                            //保存培训情况及支部意见
                            partyjointrained train = DB.partyjointraineds.Find(CurrentStandID);
                            if (train != null)
                            {
                                train.ImageUrlID = hdFileId.Text;
                                train.ID = CurrentStandID;
                                train.TrainedOpinion = this.Request.Form["editor1"];
                                train.BranchOpinion = this.Request.Form["editor2"];
                                DB.SaveChanges();
                            }
                            else
                            {
                                train = new partyjointrained();
                                train.ImageUrlID = hdFileId.Text;
                                train.ID = CurrentStandID;
                                train.TrainedOpinion = this.Request.Form["editor1"];
                                train.BranchOpinion = this.Request.Form["editor2"];
                                DB.partyjointraineds.Add(train);
                                DB.SaveChanges();
                            }
                        }

                        break;
                    case ProcesUtil.JoinStep26:
                        //申请的最高级审批组织ID
                        string TopBranchID = ModuleUtil.GetPartyAppointArray(this.ApplyBranchID);
                        if (string.IsNullOrEmpty(FilterSpecialCharacters.Filter(oModel.Remark)))
                        {
                            outMassage = string.Format("{0}不能为空!", this.Request.Form["editor1"]);
                            Alert.Show(outMassage, String.Empty, ActiveWindow.GetHideReference());
                            return;
                        }
                        bResult = ProcesUtil.ApprovalProcesStep(oModel, out Message, TopBranchID);
                        break;
                    case ProcesUtil.JoinStep4:
                    case ProcesUtil.JoinStep12:
                    case ProcesUtil.JoinStep24:
                    case ProcesUtil.JoinStep36:

                        var model = DB.partyjoinpublicitys.Where(a => a.StandID == this.CurrentStandID && a.StepID == this.CurrentStepID).FirstOrDefault();
                        if (model == null)
                        {
                            PartyJoinProcess ps = DB.PartyJoinProcesss.Find(this.CurrentStepID);
                            string st = ps.ProcessName;
                            string[] sArray = st.Split('、');
                            var app = DB.PartyJoinApplycation.Find(this.AppllicationID);
                            model = new partyjoinpublicity();
                            model.ID = StringHelper.NewID;
                            model.StandID = this.CurrentStandID;
                            model.StepID = this.CurrentStepID;
                            model.AppllicationID = this.AppllicationID;
                            model.LoginID = app.LoginID;
                            model.Category = "publicity";
                            model.Title = "关于" + app.UserName + "同志" + sArray[1] + "的信息公告";
                            model.CreateTime = DateTime.Now;
                            model.NoticeTime = txtTitle.Text;
                            DB.partyjoinpublicitys.Add(model);
                        }
                        else
                        {
                            model.NoticeTime = this.txtTitle.Text;
                            model.CreateTime = DateTime.Now;
                        }
                        oModel.Status = (int)Enum_FlowStanceStatus.未处理;
                        oModel.Remark = this.Request.Form["editor1"];
                        DB.SaveChanges();
                        oModel.Status = (int)Enum_FlowStanceStatus.通过;

                        bResult = ProcesUtil.ApprovalProcesStep(oModel, out Message);
                        break;
                    case ProcesUtil.JoinStep13:
                    case ProcesUtil.JoinStep20:
                        oModel.Remark2 = this.Request.Form["editor2"];
                        if (string.IsNullOrEmpty(FilterSpecialCharacters.Filter(oModel.Remark ?? "")))
                        {
                            outMassage = string.Format("{0}不能为空!", this.Request.Form["editor1"]);
                            Alert.Show(outMassage, String.Empty, ActiveWindow.GetHideReference());
                            return;
                        }
                        bResult = ProcesUtil.ApprovalProcesStep(oModel, out Message);
                        break;

                    default:
                        if (string.IsNullOrEmpty(FilterSpecialCharacters.Filter(oModel.Remark ?? "")))
                        {
                            outMassage = string.Format("{0}不能为空!", this.Request.Form["editor1"]);
                            Alert.Show(outMassage, String.Empty, ActiveWindow.GetHideReference());
                            return;
                        }
                        bResult = ProcesUtil.ApprovalProcesStep(oModel, out Message);
                        break;
                }
                if (this.CurrentStepID == ProcesUtil.JoinStep28)
                {
                    //发布转为党员账号  正式党员
                    ModuleUtil.UpdateUserMassage(oModel.AppllicationID, "0", "", "null");
                    bResult = true;
                }
            }
            if (bResult)
            {
                if (AdminSave)
                {
                    Alert.Show("保存成功", String.Empty, ActiveWindow.GetHideReference());
                }
                else
                {
                    Alert.Show("提交成功", String.Empty, ActiveWindow.GetHideReference());
                    //创建子流程
                    if (this.CurrentStepID == ProcesUtil.JoinStep5 || this.CurrentStepID == ProcesUtil.JoinStep13)
                    {
                        CreateChildFlow(out Message);
                    }
                }
            }
            else
            {
                if (Message != "")
                {
                    Alert.Show(Message, String.Empty, ActiveWindow.GetHideReference());
                }
            }
        }

        /// <summary>
        /// 创建子流程
        /// </summary>
        /// <param name="Message"></param>
        protected void CreateChildFlow(out string Message)
        {
            //为了生存子流程，必须把当前的（不批量操作）主流程先变为0,该方法最后再修改成为1
            var mainFlow = DB.PartyJoinLinkExamples.Find(this.CurrentStandID);
            if (mainFlow != null)
            {
                mainFlow.Status = 0;
                DB.SaveChanges();
            }
            string oMessage = "";
            DataSet ds = ModuleUtil.BranchLoginStantID(this.ApplyBranchID, this.CurrentStepID, this.CurrentStandID);
            PartyJoinLinkExample oModel = null;
            #region 提交并生成下一步待办流程实例
            //提交时产生下一步流程

            //获取上级党委ID

            string UpBranchID = Utility.GetParentBranch(this.ApplyBranchID);

            if (string.IsNullOrEmpty(UpBranchID))
            {
                UpBranchID = this.ApplyBranchID;
            }
            string ToDoHandleUserIDs = string.Empty;
            string ToDoHandleUserNames = string.Empty;
            ToDoHandleUserIDs = UpBranchID;
            ToDoHandleUserNames = UpBranchID;
            //*
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                oModel = DB.PartyJoinLinkExamples.Find(dr["StandID"].ToString());

                ProcesUtil.ApprovalProcesStep(oModel, out oMessage);

                #region 在（确认入党积极分子\确定发展对象）步聚产生下一步（报上级党委备案）子流程
                if (oModel.CurrentStepID == ProcesUtil.JoinStep5 || oModel.CurrentStepID == ProcesUtil.JoinStep13)
                {
                    PartyJoinChildFlow cFlow = new PartyJoinChildFlow();
                    cFlow.ChildFlowID = StringHelper.NewID;
                    cFlow.StandID = Convert.ToString(HttpContext.Current.Session["NextStandID"]);
                    switch (oModel.CurrentStepID)
                    {
                        case ProcesUtil.JoinStep5: cFlow.StepID = ProcesUtil.JoinStep6; break;
                        case ProcesUtil.JoinStep13: cFlow.StepID = ProcesUtil.JoinStep14; break;
                    }
                    cFlow.ApplyBranchID = this.ApplyBranchID;
                    cFlow.HandleUserID = this.ApplyBranchID;
                    cFlow.HandleUserName = this.ApplyBranchID;
                    cFlow.ToDoBranchID = UpBranchID;//上级组织
                    cFlow.ToDoHandleUserID = ToDoHandleUserIDs;
                    cFlow.ToDoHandleUserName = ToDoHandleUserNames;
                    cFlow.Status = (int)Enum_FlowStanceStatus.未处理;
                    cFlow.OrderNo = Utility.GetSortOrderNo("tblPartyJoinChildFlow", "OrderNo", "StandID='" + cFlow.StandID + "'");
                    cFlow.CreateTime = DateTime.Now;
                    DB.PartyJoinChildFlows.Add(cFlow);
                    DB.SaveChanges();
                    HttpContext.Current.Session["NextStandID"] = null;
                    #endregion
                }
            }
            #endregion
            Message = oMessage;
            mainFlow.Status = 1;
            DB.SaveChanges();
        }

        //设置页面显示内容
        protected void SetPageShowContent()
        {
            string MassageName = string.Empty;
            var oModel = DB.PartyJoinLinkExamples.Find(this.CurrentStandID);
            switch (oModel.CurrentStepID)
            {
                case ProcesUtil.JoinStep6:
                case ProcesUtil.JoinStep14:
                    MassageName = "备案审查"; break;
                case ProcesUtil.JoinStep2: MassageName = "备案内容"; break;
                //case ProcesUtil.JoinStep4:
                //case ProcesUtil.JoinStep12: //发展对象公示
                //case ProcesUtil.JoinStep24: //预备党员公示
                case ProcesUtil.JoinStep27://下发通知
                case ProcesUtil.JoinStep28://公布预备党员并编入党组织
                                           //case ProcesUtil.JoinStep36://预备党员转正公示
                case ProcesUtil.JoinStep39://谈话和公布预备党员转正
                    MassageName = "公示内容"; break;
                case ProcesUtil.JoinStep10:
                case ProcesUtil.JoinStep17:
                    MassageName = "培训情况"; this.imgPhoto.Hidden = false; this.filePhoto.Hidden = false; this.lbRegistration.Hidden = this.cpRegistration.Hidden = this.lbBranchOpinion.Hidden = this.cpBranchOpinion.Hidden = false;
                    break;

                case ProcesUtil.JoinStep19:
                    MassageName = "入党志愿书";
                    if (this.Stype)
                    { this.lbWorkGuide.Hidden = false; }
                    break;
                case ProcesUtil.JoinStep25: MassageName = "谈话情况及入党意见"; break;
                case ProcesUtil.JoinStep32:
                    MassageName = "转正申请";
                    if (this.Stype)
                    { this.lbWorkGuide.Hidden = false; }
                    break;
                case ProcesUtil.JoinStep33: MassageName = "党小组意见"; break;
                case ProcesUtil.JoinStep40: MassageName = "归档"; break;
                case ProcesUtil.JoinStep15: MassageName = "政治历史现实表现"; this.ddlPoliticalReview.Hidden = false; break;
                case ProcesUtil.JoinStep16: MassageName = "计划生育及社会治安等审查"; this.ddlPoliticalReview.Hidden = false; break;
                case ProcesUtil.JoinStep13:
                    MassageName = "备注"; this.ddlPoliticalReview.Hidden = false; this.lbBranchOpinion.Hidden = this.cpBranchOpinion.Hidden = false; this.lbBranchOpinion.Label = "请示"; this.BranchOpinionContent = oModel.Remark2; break;
                case ProcesUtil.JoinStep37:
                    MassageName = "备注"; this.ddlPoliticalReview.Hidden = false; break;
                //case ProcesUtil.JoinStep34://党支部意见
                //    this.heBranchOpinion.Hidden = false;
                //    MassageName = "党小组意见";
                //    heRegistration.Enabled = true;
                //    break;
                case ProcesUtil.JoinStep18:
                    MassageName = "确认入党介绍人";
                    break;
                case ProcesUtil.JoinStep20:
                    this.ddlPoliticalReview.Hidden = false;
                    this.lbBranchOpinion.Label = "政审报告";
                    this.lbBranchOpinion.Hidden = this.cpBranchOpinion.Hidden = false;
                    this.BranchOpinionContent = oModel.Remark2;
                    MassageName = "支部委员会审查";
                    break;
                case ProcesUtil.JoinStep21:
                    this.ddlPoliticalReview.Hidden = false;
                    MassageName = "基层党委预审";
                    break;
                case ProcesUtil.JoinStep26:
                    MassageName = "批复"; break;
                case ProcesUtil.JoinStep4: //入党积极份子公示
                case ProcesUtil.JoinStep12: //发展对象公示
                case ProcesUtil.JoinStep24: //预备党员公示
                case ProcesUtil.JoinStep36://预备党员转正公示
                    this.txtTitle.Hidden = false; this.txtTitle.Label = "公示时间(段)";
                    //this.lbRegistration.Hidden = this.cpRegistration.Hidden = true;
                    this.lbRegistration.Label = "公示情况";
                    RegistrationContent = oModel.Remark;
                    break;
                default: MassageName = "备注"; break;
            }

            this.lbRegistration.Text = MassageName;
        }
        #endregion
        /// <summary>
        /// 上传
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void filePhoto_FileSelected(object sender, EventArgs e)
        {
            var rs = UpFileBusiness.Upload(filePhoto, CurrentUser.LoginID, "个人头像");
            if (rs.IsSuccess)
            {
                hdFileId.Text = rs.FileID;
                imgPhoto.ImageUrl = "~/" + rs.FileUrl;
                imgPhoto.ImageWidth = Unit.Pixel(200);

            }
        }
        #region 按钮
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (CheckValue())
            {
                this.SaveData(true);
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
        }

        protected void btnSaveClose_Click(object sender, EventArgs e)
        {
            if (CheckValue())
            {
                SaveData(true, true);
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
        }
        #endregion

        public bool CheckValue()
        {
            bool ret = true;
            if (this.txtTitle.Text.Trim() == "")
            {
                this.txtTitle.MarkInvalid("必填");
                ret = false;
            }

            var oModel = DB.PartyJoinLinkExamples.Find(this.CurrentStandID);
            switch (oModel.CurrentStepID)
            {
                case ProcesUtil.JoinStep4: //入党积极份子公示
                case ProcesUtil.JoinStep12: //发展对象公示
                case ProcesUtil.JoinStep24: //预备党员公示
                case ProcesUtil.JoinStep36://预备党员转正公示
                    break;
                case ProcesUtil.JoinStep17://发展对象集中培训
                    if (string.IsNullOrEmpty(hdFileId.Text))
                    {
                        Alert.Show("上传证书文件不能为空，请确认！", String.Empty);
                        ret = false;
                    }
                    else
                        ret = true;
                    break;
                case ProcesUtil.JoinStep13://确定发展对象
                case ProcesUtil.JoinStep20://支部委员会审查
                case ProcesUtil.JoinStep21://基层党委预审
                case ProcesUtil.JoinStep25://组织员谈话
                case ProcesUtil.JoinStep32://提出书面转正申请
                case ProcesUtil.JoinStep33://党小组意见
                case ProcesUtil.JoinStep40://入党材料归档
                    if (string.IsNullOrEmpty(FilterSpecialCharacters.Filter(this.Request.Form["editor1"] ?? "")))
                    {
                        Alert.Show(string.Format("{0}不能为空!", this.lbRegistration.Text), String.Empty);
                        ret = false;
                    }
                    else
                        ret = true;
                    break;
                default:
                    ret = true;
                    break;
            }


            return ret;
        }
    }
}